package com.dy.controller;

import com.dy.bean.Sugar;
import com.dy.service.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @projectName: day0615
 * @package: com.dy.controller
 * @className: SugarController
 * @author: DuanYu
 * @description: TODO
 * @date: 2024/6/15 13:59
 * @version: 1.0
 */
@RestController
public class SugarController {
    @Autowired
    SugarService service;

    @RequestMapping("listJg")
    public String showJg() {
        List list = new ArrayList<>();
        list.add("机构");
        list.add("完成里程");
        list.add("完成次数");
        list.add("完运时长");
        list.add("每次平均时长");
        list.add("每次平均里程");
        return SugarUtil.getTablePlayData(list, service.showJg());
    }

    @RequestMapping("listMoney")
    public Map showMoney() {
        Map map = new HashMap<>();
        map.put("status", 0);
        Double aDouble = service.showMoney();
        map.put("data", aDouble);
        return map;
    }

    @RequestMapping("listHw")
    public Map showHw() {
        return SugarUtil.getPieData(service.showHw());
    }

    @RequestMapping("listHw2")
    public Map showHw2() {
        return SugarUtil.getPieData(service.showHw2());
    }

    @RequestMapping("listCity")
    public Map showCity() {
        return SugarUtil.getBarData(service.showCity());
    }

    @RequestMapping("listSum")
    public Map showSum() {
        Map map = new HashMap<>();
        map.put("status", 0);
        List<Sugar> sugars = service.showSum();
        map.put("data", sugars);
        return map;
    }

    @RequestMapping("listDaySum")
    public Map showDaySum() {
        Map map = new HashMap<>();
        map.put("status",0);
        Double aDouble = service.showDaySum();
        map.put("data",aDouble);
        return map;
    }
    @RequestMapping("listMap")
    public Map showMap(){
        return SugarUtil.getMapData(service.showMap());
    }
}
